package com.bbva.gptf.back.dominio;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.sql.DataSource;

import org.jfree.util.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.jdbc.core.simple.SimpleJdbcCall;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.bbva.gptf.back.util.Constantes;
import com.bbva.jee.arq.spring.core.log.I18nLog;
import com.bbva.jee.arq.spring.core.log.I18nLogFactory;

@Component
@Configurable
public class SpContratoVigen {
	
	private static final I18nLog LOG = I18nLogFactory.getLogI18n(SpContratoVigen.class);
	
	private SimpleJdbcCall simpleJdbcCall;
	
	@Autowired
	private DataSource dataSource;

    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }
    
    @PersistenceContext
    transient EntityManager entityManager;
	
    @Transactional
	public void execute(){
    	try{
    		simpleJdbcCall = new SimpleJdbcCall(this.dataSource);
    		String procedureName = Constantes.SPCONTRATOVIGENTE;        
            simpleJdbcCall.withoutProcedureColumnMetaDataAccess();
            simpleJdbcCall.withProcedureName(procedureName);
            simpleJdbcCall.execute();	
    	}catch(Exception ex){
    		Log.info(ex.toString());    		
    	}
		
	}
}
